<?php
require_once('../inc/pager.php');
switch($action){
	/************************************** verifytopic BEGIN ************************************************/
	case "verify":
	case "verifytopic":
	$dwidth=array(0,120,380,320,100);
		$curPage = numFilter($_GET["page"]);
		$pager = new Pager();
		$pager->init(5,$curPage,"admin.php?inc=topic&action=verify&page={page}");
		$rows = $pager->queryRows($db,"posts", "posts.verifystate=1 and posts.istopic=1" ,"*","posts.tid desc");

	echo <<<EOT
	<div id="smalltab_container"></div>
	<div class="smalltab_line"></div>
	<div class="div_clear" style="height:10px;"></div>
	<div id="t1">
		<form id="verifyform" onsubmit="return false;">
		<div class="tips_1"><b>提示</b><br />
	* 本功能仅在 “版块 » 版块设置 » 编辑 » 帖子审核”开启时才有效。</div>
		<div class="div_clear" style="height:10px;"></div>
		
EOT;
		echo("<table class=\"table_1\" width=\"100%\">");
		echo("<tr style=\"font-weight:bold;color:#333333;\"><td class=\"row_0\"><div class=\"rowdiv_0\" style=\"width:{$dwidth[1]}px;\">操作</div><div class=\"rowdiv_0\" style=\"width:{$dwidth[2]}px;\">版块/主题/发表者/时间</div><div class=\"rowdiv_0\" style=\"width:{$dwidth[3]}px;\">内容</div><div class=\"rowdiv_0\" style=\"width:{$dwidth[4]}px;\">操作</div></td></tr>");
		for($i=0;$i<count($rows);$i++){
			$row=$rows[$i];
			$row['title']=htmlFilter($row['title']);
			$row['username']=htmlFilter($row['username']);
			echo("<tr><td class=\"row_0\" style=\"line-height:180%;border-top:1px solid #82BBCA;\"><div class='rowdiv_0' style='width:{$dwidth[1]}px;'><input type='radio' value='0' name='doaction[{$row['tid']}]' class='radio_css' /> 忽略 <br /><input type='radio' value='1' name='doaction[{$row['tid']}]' checked='true' class='radio_css' /> 通过<br /><input type='radio' value='2' name='doaction[{$row['tid']}]' class='radio_css' /> 删除<br /></div><div class='rowdiv_0' style='width:{$dwidth[2]}px;'><span class=\"topic_title\"><a href=\"../forum.php?fid={$row[fid]}\" target=\"_blank\">{$cache_forums[$row['fid']]['forumname']}</a> » <a href=\"../view.php?tid={$row[tid]}\" target=\"_blank\">{$row['title']}</a></span><br />作者: <a href=\"../user.php?uid={$row[userid]}\" target=\"_blank\">{$row['username']}</a><br />时间: <span class='time'>".getDateStr($row['posttime'])."</span> </div><div class='rowdiv_0' style='width:{$dwidth[3]}px;'><div style='width:300px;height:60px; overflow:auto;'>{$row['content']}</div></div><div class='rowdiv_0' style='width:{$dwidth[4]}px;'><a href=\"#\">编辑</a></div>");
			echo("</td></tr>");				
		}
		echo("</table>");
		echo("<table width=100%><tr><td><input class=\"button_css\" type=\"button\" value=\"  提  交  \" onclick=\"ajax_verify()\" /></td><td><div class='pagestrdiv'>{$pager->getPageStr()}</div></td></tr></table>");
		
echo <<<EOT
		
	
	</form>
</div>
<div id="t2"></div>
<div id="t3"></div>
<div class="div_clear" style="height:30px;"></div>
<script>
var smallNowTab;
var pt = new Tabs();
pt.classpre="smalltab_";
pt.container = "smalltab_container";
pt.createTab("t1","主题审核","",true,"n");
pt.createTab("t2","回复审核","",false,"n");
pt.init = function(){
	smallNowTab = pt.nowTab;
};
pt.onclick = function(){
	if(pt.nowTab=="t2"){
		self.location.href = "admin.php?inc=topic&action=verifypost";
	}
	smallNowTab = pt.nowTab;
};		
pt.initTab();
pt.clickNowTab();
function ajax_verify(){
	popwin.loading();
	ajaxPost("verifyform","topic_ajax.php?action=verifytopic",ajax_verify_callback);
}
function ajax_verify_callback(data){
	var btns=[{value:" 确 定 ",onclick:"popwin.close();mainifm.location.reload();",focus:true}];
	popwin.loaded();
	if(data=="y"){
		popwin.showDialog(1,"审核成功","审核成功",btns,280,130);
	}else{
		popwin.showDialog(0,"审核失败","操作失败:<br />"+data,btns,280,130);
	}
}

</script>

EOT;
	break;
	/************************************** verifytopic END ************************************************/
	
	/************************************** verifypost BEGIN ************************************************/
	case "verifypost":
	$dwidth=array(0,120,380,320,100);
		$curPage = numFilter($_GET["page"]);
		$pager = new Pager();
		$pager->init(5,$curPage,"admin.php?inc=topic&action=verifypost&page={page}");
		$rows = $pager->queryRows($db,"posts,topics", "posts.verifystate=1 and posts.istopic=0 and topics.id=posts.tid","*,topics.title as title,posts.id as id,posts.username as username, posts.userid as userid, posts.posttime as posttime","posts.id desc");

	echo <<<EOT
	<div id="smalltab_container"></div>
	<div class="smalltab_line"></div>
	<div class="div_clear" style="height:10px;"></div>
	<div id="t1"></div>
<div id="t2">
		<form id="verifyform" onsubmit="return false;">
		<div class="tips_1"><b>提示</b><br />
	* 本功能仅在 “版块 » 版块设置 » 编辑 » 帖子审核”开启时才有效。</div>
		<div class="div_clear" style="height:10px;"></div>
		
EOT;
		echo("<table class=\"table_1\" width=\"100%\">");
		echo("<tr style=\"font-weight:bold;color:#333333;\"><td class=\"row_0\"><div class=\"rowdiv_0\" style=\"width:{$dwidth[1]}px;\">操作</div><div class=\"rowdiv_0\" style=\"width:{$dwidth[2]}px;\">版块/所属主题/回复者/时间</div><div class=\"rowdiv_0\" style=\"width:{$dwidth[3]}px;\">回复内容</div><div class=\"rowdiv_0\" style=\"width:{$dwidth[4]}px;\">操作</div></td></tr>");
		for($i=0;$i<count($rows);$i++){
			$row=$rows[$i];
			$row['title']=htmlFilter($row['title']);
			$row['username']=htmlFilter($row['username']);
			echo("<tr><td class=\"row_0\" style=\"line-height:180%;border-top:1px solid #82BBCA;\"><div class='rowdiv_0' style='width:{$dwidth[1]}px;'><input type='radio' value='0' name='doaction[{$row['id']}]' class='radio_css' /> 忽略 <br /><input type='radio' value='1' name='doaction[{$row['id']}]' checked='true' class='radio_css' /> 通过<br /><input type='radio' value='2' name='doaction[{$row['id']}]' class='radio_css' /> 删除<br /></div><div class='rowdiv_0' style='width:{$dwidth[2]}px;'><span class=\"topic_title\"><a href=\"../forum.php?fid={$row[fid]}\" target=\"_blank\">{$cache_forums[$row['fid']]['forumname']}</a> » <a href=\"../view.php?tid={$row[tid]}\" target=\"_blank\">{$row['title']}</a></span><br />回复: <a href=\"../user.php?uid={$row[userid]}\" target=\"_blank\">{$row['username']}</a><br />时间: <span class='time'>".getDateStr($row['posttime'])."</span> </div><div class='rowdiv_0' style='width:{$dwidth[3]}px;'><div style='width:300px;height:60px; overflow:auto;'>{$row['content']}</div></div><div class='rowdiv_0' style='width:{$dwidth[4]}px;'><a href=\"#\">编辑</a></div>");
			echo("</td></tr>");				
		}
		echo("</table>");
		echo("<table width=100%><tr><td><input class=\"button_css\" type=\"button\" value=\"  提  交  \" onclick=\"ajax_verify()\" /></td><td><div class='pagestrdiv'>{$pager->getPageStr()}</div></td></tr></table>");
		
echo <<<EOT
		
	
	</form>

</div>
<div id="t3"></div>
<div class="div_clear" style="height:30px;"></div>
<script>
var smallNowTab;
var pt = new Tabs();
pt.classpre="smalltab_";
pt.container = "smalltab_container";
pt.createTab("t1","主题审核","",false,"n");
pt.createTab("t2","回复审核","",true,"n");
pt.init = function(){
	smallNowTab = pt.nowTab;
};
pt.onclick = function(){
	if(pt.nowTab=="t1"){
		self.location.href = "admin.php?inc=topic&action=verifytopic";
	}

	smallNowTab = pt.nowTab;
};		
pt.initTab();
pt.clickNowTab();
function ajax_verify(){
	popwin.loading();
	ajaxPost("verifyform","topic_ajax.php?action=verifypost",ajax_verify_callback);
}
function ajax_verify_callback(data){
	var btns=[{value:" 确 定 ",onclick:"popwin.close();mainifm.location.reload();",focus:true}];
	popwin.loaded();
	if(data=="y"){
		popwin.showDialog(1,"审核成功","审核成功",btns,280,130);
	}else{
		popwin.showDialog(0,"审核失败","操作失败:<br />"+data,btns,280,130);
	}
}

</script>

EOT;
	break;
	/************************************** verifypost END ************************************************/


	/************************************** manager/search BEGIN ************************************************/
	case "manager":
	case "search":
	
echo <<<EOT
	<div id="smalltab_container"></div>
	<div class="smalltab_line"></div>
	<div id="t1">
EOT;
	if($action=="manager"){
echo <<<EOT
	<form onsubmit="return false;">
	<div class="div_clear" style="height:10px;"></div>
	<div class="tips_1"><b>提示</b><br />
	* 请先根据条件搜索帖子，然后选择相应的操作。<br />
	</div>
	<div class="div_clear" style="height:10px;"></div>
	<table class="table_1">
		<tr><td class="td_0">帖子ID:</td><td class=""></td></tr>
		<tr><td class="td_1"><input type="text" size="30" value="" name="tid" id="tid" class="text_css" /></td><td class="td_2"></td></tr>
		<tr><td class="td_0">标题:</td><td class=""></td></tr>
		<tr><td class="td_1"><input type="text" size="30" value="" name="title" id="title" class="text_css" /></td><td class="td_2">帖子标题关键字</td></tr>
		<tr><td class="td_0">内容:</td><td class=""></td></tr>
		<tr><td class="td_1"><input type="text" size="30" value="" name="content" id="content" class="text_css" /></td><td class="td_2">帖子内容关键字</td></tr>
		<tr><td class="td_0">作者:</td><td class=""></td></tr>
		<tr><td class="td_1"><input type="text" size="30" value="" name="username" id="username" class="text_css" /></td><td class="td_2">多用户名中间请用半角逗号 "," 分割</td></tr>
		<tr><td class="td_0">版块:</td><td class=""></td></tr>
		<tr><td class="td_1"><select size="10" multiple="multiple" style='width:200px;' name="fid" id="fid"><option value="0">所有版块</option>{$cache_forumsoption2}</select></td><td class="td_2">设置允许参与搜索的版块，可以按住 CTRL 多选</td></tr>
		<tr><td class="td_3"><input class="button_css" type="button" value="  搜 索  " onclick="searchtopic()" /></td><td class=""></td></tr>
	</table>
	</form>
EOT;
	 }else{
	 	$dwidth=array(0,35,300,100,100,120,100,200);
		$tid=numFilter($_GET['tid']);

		$title=$_GET['title'];
		//$title=str_replace("*","%",$title);
		//if($title==""){$title="%";}

		$content=$_GET['content'];
		//$content=str_replace("*","%",$content);
		//if($content==""){$content="%";}

		$username=$_GET['username'];
		$fid=$_GET['fid'];

		$cond="istopic=1";
		$cond.=(empty($title)?"":" and title like '%{$title}%'");
		$cond.=(empty($content)?"":" and content like '%{$content}%'");
		$cond.=($tid>0?" and tid={$tid}":"");
		$cond.=(empty($fid)||substr($fid,0,2)=='0,' ?"":" and fid in ({$fid})");
		$cond.=(empty($username) ?"":" and username in ({$username})");
		
		$curPage = numFilter($_GET["page"]);
		$pager = new Pager();
		$pager->init(15,$curPage,"admin.php?inc=topic&action=search&tid={$tid}&title={$title}&content={$content}&fid={$fid}&page={page}");
		$rows = $pager->queryRows($db,"posts", $cond , "*","id desc");
		
echo <<<EOT
	<div class="div_clear" style="height:10px;"></div>
	<div class="tips_1">共搜索到<b>{$pager->recordNum}</b>条记录。<a href="admin.php?inc=topic&action=manager">»返回重新搜索</a><br /></div>
EOT;
	echo("<form id=\"topicsform\" onsubmit=\"return false;\">");
	echo("<table class=\"table_1\" width=\"100%\">");
	echo("<tr style=\"font-weight:bold;color:#333333;\"><td class=\"row_0\">".
		"<div class=\"rowdiv_0\" style=\"width:{$dwidth[1]}px;\">选中</div>".
		"<div class=\"rowdiv_0\" style=\"width:{$dwidth[2]}px;\">帖子标题</div>".
		"<div class=\"rowdiv_0\" style=\"width:{$dwidth[3]}px;\">版块</div>".
		"<div class=\"rowdiv_0\" style=\"width:{$dwidth[4]}px;\">作者</div>".
		"<div class=\"rowdiv_0\" style=\"width:{$dwidth[5]}px;\">发表时间</div>");

	for($i=0;$i<count($rows);$i++){
		$row=$rows[$i];
		$row['posttime']=getDateStr($row['posttime']);
		$row['title']=htmlFilter($row['title']);
		$row['username']=htmlFilter($row['username']);
		$checkboxstr="<input type=\"checkbox\" value=\"{$row['tid']}\" name=\"tids[]\" class=\"checkbox_css\" />";

		echo("<tr><td class=\"row_0\" style=\"line-height:150%;\">".
			"<div class='rowdiv_0' style='width:{$dwidth[1]}px;'>{$checkboxstr}</div>".
			"<div class='rowdiv_0' style='width:{$dwidth[2]}px;'><a href=\"../view.php?tid={$row['tid']}\" target=\"_blank\">{$row['title']}</a>&nbsp;</div>".
			"<div class='rowdiv_0' style='width:{$dwidth[3]}px;'><a href=\"../forum.php?fid={$row['fid']}\" target=\"_blank\">{$cache_forums[$row['fid']]['forumname']}</a></div>".
			"<div class='rowdiv_0' style='width:{$dwidth[4]}px;'><a href=\"../user.php?uid={$row['userid']}\" target=\"_blank\">{$row['username']}</a></div>".
			"<div class='rowdiv_0' style='width:{$dwidth[5]}px;'><span class='time'>{$row['posttime']}</span></div>");				
	}
	echo("</table>");
	echo("<table width=100%><tr><td><input type=\"checkbox\" onclick=\"selectall(this.checked)\" class=\"checkbox_css\" /> 全选</td><td><div class='pagestrdiv'>{$pager->getPageStr()}</div></td></tr></table>");
echo <<<EOT

	<div class="div_clear" style="height:10px;"></div>
	<div class="tips_1">请选择对上面选中的帖子的操作</div>
	<table width="100%">
		<tr><td>
	<select onchange="changeAction()" id="postaction" name="postaction">
		<option value="NOTHING">请选择操作</option>
		<optgroup label="------------------------">
			<option value="movePost">移动至版块</option>
			<option value="delPost">删除</option>
			<option value="upPost">提升</option>
			<option value="stampPost">鉴定</option>
			<option value="highlightPost">高亮</option>
		</optgroup>
		<optgroup label="------------------------">
			<option value="coverPost">屏蔽帖子内容</option>
			<option value="coverPost_">解除屏蔽</option>
		</optgroup>
		<optgroup label="------------------------">
			<option value="lockPost">锁定帖子</option>
			<option value="lockPost_">解锁帖子</option>
		</optgroup>
		<optgroup label="------------------------">
			<option value="topPost">置顶</option>
			<option value="topPost_">解除置顶</option>
		</optgroup>
		<optgroup label="------------------------">
			<option value="alltopPost">总置顶</option>
			<option value="alltopPost_">解除总置顶</option>
		</optgroup>
		<optgroup label="------------------------">
			<option value="goodPost">设置为精华</option>
			<option value="goodPost_">取消精华</option>
		</optgroup>
	</select>
	<select name="movetofid" id="movetofid" style="display:none;">{$cache_forumsoption2}</select>
	<select name="stampid" id="stampid" style="display:none;"><option value="0">取消鉴定</option><option value="1">鉴定1</option><option value="2">鉴定2</option></select>
	<span id="highlightopt" style="display:none;">
		<input type="text" class="text_css" size="8" style="" value="" id="highlightcolor" name="highlightfontC" onfocus="colorpicker.choose(event);" /> <img src="../images/ico_color.gif" align="absmiddle" border="0" id="img_color" class="colorpicker" onclick="colorpicker.choose(event);" /> &nbsp; 
		<input type="checkbox" value="1" name="highlightfontB[]" id="highlightfontB" class="checkbox_css" /> <b>B</b>
		<input type="checkbox" value="1" name="highlightfontI[]" id="highlightfontI" class="checkbox_css" /> <i>I</i> 
		<input type="checkbox" value="1" name="highlightfontU[]" id="highlightfontU" class="checkbox_css" /> <u>U</u>
	</span>
	</td></tr>
		<tr><td><input type="button" class="button_css" value=" 提 交 " onclick="ajax_dotopics_yn()" /></td></tr>
	</table>	

EOT;
	echo("</form>");

 	}
echo <<<EOT
	</div>
	<div id="t2"></div>
	<div id="t3"></div>
	<div class="div_clear" style="height:30px;"></div>
<script>
var smallNowTab;
var pt = new Tabs();
pt.classpre="smalltab_";
pt.container = "smalltab_container";
pt.createTab("t1","帖子管理","",true,"n");
//pt.createTab("t2","批量删除","",false,"n");
pt.init = function(){
	smallNowTab = pt.nowTab;
};
pt.onclick = function(){
	smallNowTab = pt.nowTab;
};		
pt.initTab();
pt.clickNowTab();

function selectall(b){
	var oForm=getE("topicsform");
	for (var i = 0; i < oForm.elements.length; i++) {
		if(oForm.elements[i].type=="checkbox"&&!oForm.elements[i].disabled){
			oForm.elements[i].checked = b;
		}
	}
}

function searchtopic(){
	var loc = "admin.php?inc=topic&action=search&tid="+document.getElementById("tid").value+"&title="+document.getElementById("title").value+"&content="+document.getElementById("content").value+"&fid="+getMultipleValue(document.getElementById("fid"));
	self.location.href = loc;
}

function changeAction(){
	var d = E("postaction").value;
	setDisplay("movetofid",d=="movePost");
	setDisplay("stampid",d=="stampPost");
	setDisplay("highlightopt",d=="highlightPost");
}

function ajax_dotopics_yn(){
	if(E("postaction").value=="NOTHING"){
		var btns=[
				{value:" 确 认 ",onclick:"popwin.close()",focus:true}
		];
		popwin.showDialog(2,"提示","请选择对帖子的操作。",btns,320,130);
		return;
	}
	var btns=[
		{value:" 确 认 ",onclick:"mainifm.ajax_dotopics()",focus:true},
		{value:" 取 消 ",onclick:"popwin.close()"}
	];
	popwin.showDialog(3,"确认","您选择了批量操作，该操作的完成可能需要等待一些时间。<br />是否确认继续？",btns,320,130);
}

function ajax_dotopics(){
	popwin.loading();
	ajaxPost("topicsform","topic_ajax.php?action=dotopics",ajax_dotopics_callback);
}
function ajax_dotopics_callback(data){
	var btns=[{value:" 确 定 ",onclick:"popwin.close();mainifm.location.reload();",focus:true}];
	popwin.loaded();
	if(data=="y"){
		popwin.showDialog(1,"操作成功","批量操作成功",btns,280,130);
	}else{
		popwin.showDialog(0,"操作失败","操作失败:<br />"+data,btns,280,130);
	}
}


function PageInit(){
	if(E("tid")){E("tid").onkeyup = function(event){checkKeyPressEnter(event);};E("tid").focus();}
	if(E("title")){E("title").onkeyup = function(event){checkKeyPressEnter(event);};}
	if(E("content")){E("content").onkeyup = function(event){checkKeyPressEnter(event);};}
	if(E("username")){E("username").onkeyup = function(event){checkKeyPressEnter(event);};}
	colorpicker.previewColor = function(color){
		color=color==""?"#000000":color;
		colorChanged(color);
	}
	colorpicker.chooseColor = function(color){
		color=color==""?"#000000":color;
		colorChanged(color);
	}
}
function colorChanged(color){
	E("highlightcolor").style.color = color;
	E("highlightcolor").value = color;		
}

function checkKeyPressEnter(eventobject){
	var eve=eventobject||window.event;
	if(eve.keyCode==13) {
		searchtopic();
	}
}
window.onload=PageInit;

</script>
EOT;
	break;
	/**************************************  manager/search END ************************************************/

	/************************************** recycle BEGIN ************************************************/
	case "recycle":
echo <<<EOT
	<div id="smalltab_container"></div>
	<div class="smalltab_line"></div>
	<div id="t1">
EOT;
	{
	 	$dwidth=array(0,35,300,100,100,120,100,200);
		$cond="isrecycle=1";
		$curPage = numFilter($_GET["page"]);
		$pager = new Pager();
		$pager->init(15,$curPage,"admin.php?inc=topic&action=recycle&page={page}");
		$rows = $pager->queryRows($db,"topics", $cond , "*","id desc");
		
echo <<<EOT
	<div class="div_clear" style="height:10px;"></div>
	<div class="tips_1">回收站共有<b>{$pager->recordNum}</b>条记录。</div>
EOT;
	echo("<form id=\"topicsform\" onsubmit=\"return false;\">");
	echo("<table class=\"table_1\" width=\"100%\">");
	echo("<tr style=\"font-weight:bold;color:#333333;\"><td class=\"row_0\">".
		"<div class=\"rowdiv_0\" style=\"width:{$dwidth[1]}px;\">选中</div>".
		"<div class=\"rowdiv_0\" style=\"width:{$dwidth[2]}px;\">帖子标题</div>".
		"<div class=\"rowdiv_0\" style=\"width:{$dwidth[3]}px;\">版块</div>".
		"<div class=\"rowdiv_0\" style=\"width:{$dwidth[4]}px;\">作者</div>".
		"<div class=\"rowdiv_0\" style=\"width:{$dwidth[5]}px;\">发表时间</div>");

	for($i=0;$i<count($rows);$i++){
		$row=$rows[$i];
		$row['posttime']=getDateStr($row['posttime']);
		$row['title']=htmlFilter($row['title']);
		$row['username']=htmlFilter($row['username']);
		$checkboxstr="<input type=\"checkbox\" value=\"{$row['id']}\" name=\"tids[]\" class=\"checkbox_css\" />";

		echo("<tr><td class=\"row_0\" style=\"line-height:150%;\">".
			"<div class='rowdiv_0' style='width:{$dwidth[1]}px;'>{$checkboxstr}</div>".
			"<div class='rowdiv_0' style='width:{$dwidth[2]}px;'><a href=\"../view.php?tid={$row['id']}\" target=\"_blank\">{$row['title']}</a>&nbsp;</div>".
			"<div class='rowdiv_0' style='width:{$dwidth[3]}px;'><a href=\"../forum.php?fid={$row['fid']}\" target=\"_blank\">{$cache_forums[$row['fid']]['forumname']}</a></div>".
			"<div class='rowdiv_0' style='width:{$dwidth[4]}px;'><a href=\"../user.php?uid={$row['userid']}\" target=\"_blank\">{$row['username']}</a></div>".
			"<div class='rowdiv_0' style='width:{$dwidth[5]}px;'><span class='time'>{$row['posttime']}</span></div>");				
	}
	echo("</table>");
	echo("<table width=100%><tr><td><input type=\"checkbox\" onclick=\"selectall(this.checked)\" class=\"checkbox_css\" /> 全选</td><td><div class='pagestrdiv'>{$pager->getPageStr()}</div></td></tr></table>");
echo <<<EOT

	<div class="div_clear" style="height:10px;"></div>
	<div class="tips_1">请选择对上面选中的帖子的操作</div>
	<table width="100%">
		<tr><td>
	<select id="postaction" name="postaction">
		<option value="NOTHING">请选择操作</option>
		<option value="delPost">彻底删除</option>
		<option value="restorePost">还原帖子</option>
	</select>
	</td></tr>
		<tr><td><input type="button" class="button_css" value="  提  交  " onclick="ajax_dotopics_yn()" /> <input type="button" class="button_css" value=" 清空回收站 " onclick="ajax_clean_yn()" /></td></tr>
	</table>	

EOT;
	echo("</form>");

 	}
echo <<<EOT
	</div>
	<div id="t2"></div>
	<div id="t3"></div>
	<div class="div_clear" style="height:30px;"></div>
<script>
var smallNowTab;
var pt = new Tabs();
pt.classpre="smalltab_";
pt.container = "smalltab_container";
pt.createTab("t1","回收站","",true,"n");
//pt.createTab("t2","批量删除","",false,"n");
pt.init = function(){
	smallNowTab = pt.nowTab;
};
pt.onclick = function(){
	smallNowTab = pt.nowTab;
};		
pt.initTab();
pt.clickNowTab();

function selectall(b){
	var oForm=getE("topicsform");
	for (var i = 0; i < oForm.elements.length; i++) {
		if(oForm.elements[i].type=="checkbox"&&!oForm.elements[i].disabled){
			oForm.elements[i].checked = b;
		}
	}
}

function ajax_dotopics_yn(){
	var btns=[
		{value:" 确 认 ",onclick:"mainifm.ajax_dotopics()",focus:true},
		{value:" 取 消 ",onclick:"popwin.close()"}
	];
	popwin.showDialog(3,"确认","您选择了批量操作，该操作的完成可能需要等待一些时间。<br />是否确认继续？",btns,320,130);
}


function ajax_clean_yn(){
	var btns=[
		{value:" 确 认 ",onclick:"mainifm.ajax_clean()",focus:true},
		{value:" 取 消 ",onclick:"popwin.close()"}
	];
	popwin.showDialog(3,"确认","确认清空回收站，该操作不可恢复。<br />是否确认继续？",btns,320,130);
}


function ajax_clean(){
	popwin.loading();
	ajaxPost("topicsform","topic_ajax.php?action=clean",ajax_clean_callback);
}
function ajax_clean_callback(data){
	var btns=[{value:" 确 定 ",onclick:"popwin.close();mainifm.location.reload();",focus:true}];
	popwin.loaded();
	if(data=="y"){
		popwin.showDialog(1,"操作成功","成功清空回收站。",btns,280,130);
	}else{
		popwin.showDialog(0,"操作失败","操作失败:<br />"+data,btns,280,130);
	}
}

function ajax_dotopics(){
	popwin.loading();
	ajaxPost("topicsform","topic_ajax.php?action=dotopics",ajax_dotopics_callback);
}
function ajax_dotopics_callback(data){
	var btns=[{value:" 确 定 ",onclick:"popwin.close();mainifm.location.reload();",focus:true}];
	popwin.loaded();
	if(data=="y"){
		popwin.showDialog(1,"操作成功","批量操作成功",btns,280,130);
	}else{
		popwin.showDialog(0,"操作失败","操作失败:<br />"+data,btns,280,130);
	}
}

</script>
EOT;
	break;
	/**************************************  recycle END ************************************************/

	/************************************** dirtywords BEGIN ************************************************/
	case "dirtywords":
	$rows=$db->row_select("dirtywords","type=0",0,"*","id");
	$dwidth=array(0,50,250,250,150);

echo <<<EOT
<script>
var maxIndex=0;
function addDirtyWord(dirtywordid, wordvalue, replaceto, doaction){
	var namepre='dirtywords';
	if(dirtywordid==''){
		namepre='newdirtywords';
	}

	var da0= (doaction*1==0?"<option value='0' selected=true>替换</option>":"<option value='0'>替换</option>");
	var da1= (doaction*1==1?"<option value='1' selected=true>待审核</option>":"<option value='1'>待审核</option>");
	var da2= (doaction*1==2?"<option value='2' selected=true>禁止发帖</option>":"<option value='2'>禁止发帖</option>");
	var doactionselect="<select name='"+namepre+"_doaction["+dirtywordid+"]'>"+da0+da1+da2+"</select>";

	var s="<table class=\"table_1\" width=\"100%\"><tr><td class=\"td_6\"><div class=\"rowdiv_0\" style=\"width:{$dwidth[1]}px;\"><input type=\"checkbox\" value=\""+dirtywordid+"\" name=\""+namepre+"_delid[]\" class=\"checkbox_css\" /></div><div class=\"rowdiv_0\" style=\"width:{$dwidth[2]}px;\"><input type=\"text\" size=\"35\" value=\""+wordvalue+"\" name=\""+namepre+"_word["+dirtywordid+"]\" class=\"text_css\" /></div><div class=\"rowdiv_0\" style=\"width:{$dwidth[3]}px;\"><input type='text' value='"+replaceto+"' size='35' name='"+namepre+"_replaceto["+dirtywordid+"]' class=\"text_css\" /></div><div class=\"rowdiv_0\" style=\"width:{$dwidth[4]}px;\">"+doactionselect+"</div></td></tr></table>";
	var ele=document.createElement('div');
	ele.id="dw_div_"+maxIndex;
	ele.innerHTML=s;
	E("dirtywordsdiv").appendChild(ele);
	maxIndex++;
}
</script>

	<div id="smalltab_container"></div>
	<div class="smalltab_line"></div>
	<div class="div_clear" style="height:10px;"></div>
	<div id="t1">
		<form id="dirtywordsform" onsubmit="return false;">
		<div class="tips_1"><b>提示</b><br />
	* 请填写要过滤的关键字、替换为相应的字词，以及选择匹配到关键字时候的处理方法。<br /></div>
		<div class="div_clear" style="height:10px;"></div>
		<table class="table_1" width="100%">
			<tr style="font-weight:bold;color:#333333;"><td class="td_6"><div class="rowdiv_0" style="width:{$dwidth[1]}px;"><span class="warning">删除</span></div><div class="rowdiv_0" style="width:{$dwidth[2]}px;">关键字</div><div class="rowdiv_0" style="width:{$dwidth[3]}px;">替换</div><div class="rowdiv_0" style="width:{$dwidth[4]}px;">处理</div></td></tr>
		</table>
		<div id="dirtywordsdiv">
EOT;
			for($i=0;$i<count($rows);$i++){
				$row=$rows[$i];
				echo("<script>addDirtyWord(\"{$row['id']}\",\"{$row['word']}\",\"{$row['replaceto']}\",\"{$row['doaction']}\");</script>");			
			}
			
echo <<<EOT
		</div>
			<table class="table_1" width="100%">
			<tr><td class="td_6"><a class="td_5_1a" href="javascript:addDirtyWord('','','','')"><img src="images/ico_add.gif" border="0" /> 添加关键字</a></td></tr>
			<tr><td class="td_3"><input class="button_css" type="button" value="  提  交  " onclick="ajax_dirtywords()" /></td></tr>
		</table>
		</form>
	</div>
	<div id="t2"></div>
	<div id="t3"></div>
	<div class="div_clear" style="height:30px;"></div>
<script>
var hasErr=false;
var smallNowTab;
var pt = new Tabs();
pt.classpre="smalltab_";
pt.container = "smalltab_container";
pt.createTab("t1","关键字过滤","",true,"n");
pt.init = function(){
	smallNowTab = pt.nowTab;
};
pt.onclick = function(){
	smallNowTab = pt.nowTab;
};		
pt.initTab();
pt.clickNowTab();

function ajax_dirtywords(){
	popwin.loading();
	ajaxPost("dirtywordsform","topic_ajax.php?action=savedirtywords",ajax_dirtywords_callback);
}
function ajax_dirtywords_callback(data){
	var btns=[{value:" 确 定 ",onclick:"popwin.close();mainifm.location.reload();",focus:true}];
	popwin.loaded();
	if(data=="y"){
		popwin.showDialog(1,"编辑成功","关键字编辑成功",btns,280,130);
	}else{
		popwin.showDialog(0,"操作失败","操作失败:<br />"+data,btns,280,130);
	}
}

</script>

EOT;
	break;
	/************************************** dirtywords END ************************************************/


}	
?>